package main

import (
	"encoding/json"
	"fmt"
	"os"
)

const pathEnvName = "C_MD_TOOL_CONF_PATH"

type Config struct {
	Path   string
	Ignore []string

	GitRepoUrl string
	ZhihuOut   string // 2zhihu的输出文档
}

func getConfig(path string) *Config {
	if path == "" {
		path = os.Getenv(pathEnvName)
	}

	if path == "" {
		fmt.Println("not found env: ", pathEnvName, ", please set it")
		os.Exit(0)
	}

	f, err := os.Open(path)
	if err != nil {
		panic(err)
	}

	config := new(Config)
	if err := json.NewDecoder(f).Decode(config); err != nil {
		panic(err)
	}
	return config
}
